/**  
 * Project Name:zj-quartz  
 * File Name:ScheduleServiceImpl.java  
 * Package Name:com.zhizai.zhujian.service.impl  
 * Date:2018年8月31日下午3:17:53  
 * Copyright (c) 2018, chenzhou1025@126.com All Rights Reserved.  
 *  
*/

package com.zhizai.zhujian.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.zhizai.zhujian.dao.ScheduleMapper;
import com.zhizai.zhujian.entity.Schedule;
import com.zhizai.zhujian.service.ScheduleService;
import com.zhizai.zhujian.utils.Constants;
import com.zhizai.zhujian.utils.IdGenerate;

/**
 * ClassName:ScheduleServiceImpl <br/>
 * Function: TODO ADD FUNCTION. <br/>
 * Reason: TODO ADD REASON. <br/>
 * Date: 2018年8月31日 下午3:17:53 <br/>
 * 
 * @author feichao
 */

@Service
@Transactional
public class ScheduleServiceImpl implements ScheduleService
{
    @Autowired
    private ScheduleMapper scheduleMapper;
    
    public String insertSchedule(Schedule schedule)
    {
        try
        {
            schedule.setId(IdGenerate.getId());
            scheduleMapper.insert(schedule);
            return Constants.SUCCESS;
        }
        catch (Exception e)
        {
            e.printStackTrace();
            return Constants.FAIL;
        }
    }
    
    public String updateSchedule(Schedule schedule)
    {
        try
        {
            scheduleMapper.updateByPrimaryKeySelective(schedule);
            return Constants.SUCCESS;
        }
        catch (Exception e)
        {
            e.printStackTrace();
            return Constants.FAIL;
        }
    }
    
    public String deleteSchedule(Schedule schedule)
    {
        try
        {
            scheduleMapper.deleteByPrimaryKey(schedule.getId());
            return Constants.SUCCESS;
        }
        catch (Exception e)
        {
            e.printStackTrace();
            return Constants.FAIL;
        }
    }
    
    public List<Schedule> selectSchedules(Schedule schedule)
    {
        try
        {
            return scheduleMapper.selectSchedule(schedule);
        }
        catch (Exception e)
        {
            e.printStackTrace();
            return null;
        }
    }
    
    public List<Schedule> getSchedules(String label)
    {
        return null;
    }
    
}
